﻿@using Resources.Accessibility
@{
    var grid = Html.DevExpress().GridView(
        settings => {
            settings.Name = "grid";
            settings.CallbackRouteValues = new { Controller = "Accessibility", Action = "LocalizationPartial" };
            settings.Width = Unit.Percentage(100);

            settings.KeyFieldName = "EmployeeID";
            settings.SettingsEditing.EditFormColumnCount = 3;
            settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Accessibility", Action = "LocalizationUpdatePartial" };
            settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Accessibility", Action = "LocalizationAddNewPartial" };

            settings.CommandColumn.VisibleIndex = 0;
            settings.CommandColumn.ShowEditButton = true;
            settings.CommandColumn.ShowNewButtonInHeader = true;
            settings.Columns.Add("FirstName", Localization.FirstName);
            settings.Columns.Add("LastName", Localization.LastName);
            settings.Columns.Add("HomePhone", Localization.HomePhone);
            settings.Columns.Add(column => {
                column.FieldName = "BirthDate";
                column.Caption = Localization.BirthDate;
                column.ColumnType = MVCxGridViewColumnType.DateEdit;

                DateEditProperties deProperties = column.PropertiesEdit as DateEditProperties;
                deProperties.DisplayFormatString = "d";
                deProperties.DisplayFormatInEditMode = true;
            });
            settings.Columns.Add(column => {
                column.FieldName = "HireDate";
                column.Caption = Localization.HireDate;
                column.ColumnType = MVCxGridViewColumnType.DateEdit;

                DateEditProperties deProperties = column.PropertiesEdit as DateEditProperties;
                deProperties.DisplayFormatString = "d";
                deProperties.DisplayFormatInEditMode = true;
            });

            settings.Settings.ShowGroupPanel = true;
            settings.Settings.ShowFilterRow = true;
            settings.Settings.ShowFilterRowMenu = true;
            settings.SettingsPager.PageSize = 5;
            settings.SettingsPager.PageSizeItemSettings.Visible = true;
            settings.SettingsPager.PageSizeItemSettings.ShowAllItem = true;
    });
    
    if(ViewData["EditError"] != null) {
        grid.SetEditErrorText((string)ViewData["EditError"]);
    }
}

@grid.Bind(Model).GetHtml()